www.gusucode.com > 超声波测量以及形成图像 对相关信号进行模拟仿真 > 超声波测量以及形成图像 对相关信号进行模拟仿真/digital holograpy/prog/PMC.m
function [ b,varargout ] = PMC( a,r,us ) %PMC Phase Map Compression by data dropping % Syntax: % [ b ] = PMC( a,r,us ) % [ b,rnew ] = PMC( a,r,us ) % % a and r have the same size, partition a and r into many % us by us units, in every unit of a, the pixel corresponding % to the maximum r value is retained, and other pixels % are droped, the compressed phase is stored in b, the % optional output rnew is a matrix composed of the maximum % values of r in every unit if nargout>2 error('Too many output arguments') end [M,N]=size(a); rm=rem(M,us); rn=rem(N,us); if rm>0 a(M-rm+1:M,:)=[]; r(M-rm+1:M,:)=[]; end if rn>0 a(:,N-rn+1:N)=[]; r(:,N-rn+1:N)=[]; end [M,N]=size(a); for n=1:us for m=1:us k=(n-1).*us+m; a1(:,:,k)=a(m:us:end,n:us:end); r1(:,:,k)=r(m:us:end,n:us:end); end end clear a r maxr1=max(r1,[],3); t=repmat(maxr1,[1,1,us.*us]); t=(r1==t); clear r1; b=sum(a1.*t,3); t=sum(t,3); b=b./t; if nargout>1 varargout{1}=maxr1; end